import os, pygame

data_py = os.path.abspath(os.path.dirname(__file__))
data_dir = os.path.normpath(os.path.join(data_py, '..', 'data'))

def filepath(filename):
    return os.path.join(data_dir, filename)

def load(filename, mode='rb'):
    return open(os.path.join(data_dir, filename), mode)

def loadImage( filename ):
    filename = filepath(filename)

    try:
        image = pygame.image.load( filename )
    except pygame.error, message:
        print "Cannot load image:", filename
        raise SystemExit, message
    return image.convert_alpha()